/*
 * Copyright (c) 2021. Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. 
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. 
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. 
 * Vestibulum commodo. Ut rhoncus gravida arcu. 
 */

import java.io.IOException;
import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) throws IOException {
//        int temp = System.in.read();
//        System.out.println(temp);
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入一个整数:");
        int temp = scanner.nextInt();//可能抛出异常:InputMismatchException
        System.out.println("您刚刚输入的整数是:"+temp);

        System.out.println("请输入一个浮点数:");
        float f1 = scanner.nextFloat();//nextXXX的方法都是阻塞的
        System.out.println("您刚刚输入的浮点数是:"+f1);

        System.out.println("请输入true|false");
        boolean b1 = scanner.nextBoolean();
        System.out.println("您刚刚输入了:"+b1);
        if(b1){
//            return ;
            System.exit(0);
        }

        System.out.println("请输入姓名");
        scanner.nextLine();//去掉空行
        String name = scanner.nextLine();
        System.out.println("您输入的姓名是:"+name);

        System.out.println("请输入男|女:");
        char sex = scanner.nextLine().charAt(0);
        System.out.println("您输入了"+sex);
    }
}
